Micron Document
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| SparkN0de-git | SparkN0de |
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


Displaying Raw • Download


meshchatx/src/backend/android_rnode/__init__.py b0d47b9ece2aac27f9b52d71eead961754287bf5 (b0d47b9e) Text, 1.68 KB

T8b949e# SPDX-License-Identifier: 0BSD
T8b949e"""Install Chaquopy RNode USB / Bluetooth support before RNS starts."""

Tff7b72from T7ee787__future__ Tff7b72import Te6edf3annotations

Tff7b72import T7ee787logging

Te6edf3logger Tff7b72= Te6edf3loggingTff7b72.Td2a8ffgetLoggerTb4b4b4(Tff7b72__name__Tb4b4b4)


Tff7b72def Td2a8ffinstall_android_rnode_supportTb4b4b4(Te6edf3activityTff7b72=Tff7b72NoneTb4b4b4) Tff7b72-Tff7b72> Tffa657boolTb4b4b4:
T8b949e"""Wire Activity context into usb4a and org.able.BLE.

Returns True when the Android RNode support path was configured.
Safe to call on desktop (no-op when Chaquopy java APIs are missing).
"""
Tff7b72if Te6edf3activity Tff7b72is Tff7b72NoneTb4b4b4:
Te6edf3loggerTff7b72.Td2a8ffwarningTb4b4b4(Ta5d6ff"Ta5d6ffinstall_android_rnode_support called without ActivityTa5d6ff"Tb4b4b4)
Tff7b72return Tff7b72False

Te6edf3configured Tff7b72= Tff7b72False

Tff7b72tryTb4b4b4:
Tff7b72from T7ee787java Tff7b72import Te6edf3jclass

Te6edf3ble_cls Tff7b72= Te6edf3jclassTb4b4b4(Ta5d6ff"Ta5d6fforg.able.BLETa5d6ff"Tb4b4b4)
Te6edf3ble_clsTff7b72.Td2a8ffsetAppContextTb4b4b4(Te6edf3activityTb4b4b4)
Te6edf3configured Tff7b72= Tff7b72True
Te6edf3loggerTff7b72.Td2a8ffinfoTb4b4b4(Ta5d6ff"Ta5d6ffConfigured org.able.BLE app context for RNode BLETa5d6ff"Tb4b4b4)
Tff7b72except Tf85149Exception Tff7b72as Te6edf3excTb4b4b4:
Te6edf3loggerTff7b72.Td2a8ffwarningTb4b4b4(Ta5d6ff"Ta5d6ffCould not configure org.able.BLE context: Tffd700%sTa5d6ff"Tb4b4b4, Te6edf3excTb4b4b4)

Tff7b72tryTb4b4b4:
Tff7b72from T7ee787usb4a Tff7b72import Te6edf3usb Tff7b72as Te6edf3usb4a_usb

Te6edf3usb4a_usbTff7b72.Td2a8ffset_contextTb4b4b4(Te6edf3activityTb4b4b4)
Te6edf3configured Tff7b72= Tff7b72True
Te6edf3loggerTff7b72.Td2a8ffinfoTb4b4b4(Ta5d6ff"Ta5d6ffConfigured usb4a context for RNode USB serialTa5d6ff"Tb4b4b4)
Tff7b72except Tf85149Exception Tff7b72as Te6edf3excTb4b4b4:
Te6edf3loggerTff7b72.Td2a8ffwarningTb4b4b4(Ta5d6ff"Ta5d6ffCould not configure usb4a context: Tffd700%sTa5d6ff"Tb4b4b4, Te6edf3excTb4b4b4)

Tff7b72tryTb4b4b4:
Tff7b72import T7ee787jnius T8b949e# noqa: F401

Te6edf3loggerTff7b72.Td2a8ffinfoTb4b4b4(Ta5d6ff"Ta5d6ffjnius Chaquopy shim importable for RNode serial/BluetoothTa5d6ff"Tb4b4b4)
Tff7b72except Tf85149Exception Tff7b72as Te6edf3excTb4b4b4:
Te6edf3loggerTff7b72.Td2a8ffwarningTb4b4b4(Ta5d6ff"Ta5d6ffjnius shim not importable: Tffd700%sTa5d6ff"Tb4b4b4, Te6edf3excTb4b4b4)

Tff7b72tryTb4b4b4:
Tff7b72import T7ee787able T8b949e# noqa: F401

Te6edf3loggerTff7b72.Td2a8ffinfoTb4b4b4(Ta5d6ff"Ta5d6ffable BLE package importable for RNode ble:// portsTa5d6ff"Tb4b4b4)
Tff7b72except Tf85149Exception Tff7b72as Te6edf3excTb4b4b4:
Te6edf3loggerTff7b72.Td2a8ffwarningTb4b4b4(Ta5d6ff"Ta5d6ffable package not importable: Tffd700%sTa5d6ff"Tb4b4b4, Te6edf3excTb4b4b4)

Tff7b72return Te6edf3configured


──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────